Ext.define('XTFrame.controller.ruiyuan.Recruitment', {
	extend: 'Ext.app.Controller',
	init: function(){
		this.control({
			'ruiyuanRecruitmentEditWindow xtframeIframe': {
				iframeOnload: function (o){
					var form = o.up('ruiyuanRecruitmentEditWindow').down('form').getForm();
					o.iframe.setContent(form.findField("content").getValue());
				}
			},
			'ruiyuanRecruitmentManager': {
				beforeupdate: function(grid, win, mark, opt, row){
					var form, ifr;
					if(mark=='add' || mark=='edit'){
						win = viewFactory.getWindow(grid.editWinId, grid.editWindow);
						win.show();
						ifr = win.down('xtframeIframe');
						if(ifr.iframe != null){
							if(mark == 'edit'){
								ifr.iframe.setContent(row.data.content);
							} else if(mark == 'add') {
								ifr.iframe.setContent("");
							}
						}
					} else if(mark == 'editsave'){
						ifr = win.down('xtframeIframe');
						form = win.down('form').getForm();
						form.findField("content").setValue(ifr.iframe.getContent());
						
						if(win.flag=='add'){
							var serverData = ajaxUtil.serverData("regid","ry_jobid");
							if(ajaxUtil.isSucceed(serverData)){
								var newsid = serverData.retData;
								form.findField("job_id").setValue(newsid);
							} else {
								Ext.xtframe.msg("提示", "保存失败！");
								opt.flag = false;
							}
						}
					}
				}
			}
		});
	}
});